
export default{
    AlertWin(text){
        var newNode = document.createElement("div");
        newNode.id="mask_f";
        newNode.innerHTML ="<span>"+text+"</span>";
        document.body.appendChild(newNode);
        setTimeout(function(){
            document.body.removeChild(document.getElementById("mask_f"));
        },1000)
    },
    timeago(dateTimeStamp){  
        var result=''
        //dateTimeStamp13位数的。
       var minute = 1000 * 60;      //把分，时，天，周，半个月，一个月用毫秒表示
       var hour = minute * 60;
       var day = hour * 24;
       var week = day * 7;
       var halfamonth = day * 15;
       var month = day * 30;
       var now = new Date().getTime();   //获取当前时间毫秒
       //console.log(now)
       var diffValue = now - dateTimeStamp;//时间差
     
       if(diffValue < 0){
           return;
       }
       var minC = diffValue/minute;  //计算时间差的分，时，天，周，月
       var hourC = diffValue/hour;
       var dayC = diffValue/day;
       var weekC = diffValue/week;
       var monthC = diffValue/month;
       if(monthC >= 1 && monthC <= 3){
           result = " " + parseInt(monthC) + "月前"
       }else if(weekC >= 1 && weekC <= 3){
           result = " " + parseInt(weekC) + "周前"
       }else if(dayC >= 1 && dayC <= 6){
           result = " " + parseInt(dayC) + "天前"
       }else if(hourC >= 1 && hourC <= 23){
           result = " " + parseInt(hourC) + "小时前"
       }else if(minC >= 1 && minC <= 59){
           result =" " + parseInt(minC) + "分钟前"
       }else if(diffValue >= 0 && diffValue <= minute){
           result = "刚刚"
       }else {
           var datetime = new Date();
           datetime.setTime(dateTimeStamp);
           var Nyear = datetime.getFullYear();
           var Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
           var Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
           var Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
           var Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
           var Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
           result = Nyear + "-" + Nmonth + "-" + Ndate
       }
       return result;
    },
    timechange(time){
        // 日期转13位时间戳
        //var date = '2015-03-05 17:59:00.0';
        time = time.substring(0,19);    
        time = time.replace(/-/g,'/'); 
        var timestamp = new Date(time).getTime();
        return timestamp
    },
    formatSeconds(result) {
        // 秒转时分秒
        var h = Math.floor(result / 3600) < 10 ? '0'+Math.floor(result / 3600) : Math.floor(result / 3600);
        var m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
        var s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
        return result = h + ":" + m + ":" + s;
        
    }

    
}
let elementStyle = document.createElement('div').style
let vendor = (() => {
    let transformNames = {
      webkit: 'webkitTransform',
      Moz: 'MozTransform',
      O: 'OTransform',
      ms: 'msTransform',
      standard: 'transform'
    }
  
    for (let key in transformNames) {
      if (elementStyle[transformNames[key]] !== undefined) {
        return key
      }
    }
  
    return false
})()

export function prefixStyle(style) {
    if (vendor === false) {
      return false
    }
  
    if (vendor === 'standard') {
      return style
    }
    // 拼接 eg：webkitTransform
    return vendor + style.charAt(0).toUpperCase() + style.substr(1)
}


